﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended"
                    xmlns:wpf="http://schemas.microsoft.com/wpf/2008/toolkit"
                    xmlns:Converters="clr-namespace:NMortgage.UI.Converters"
                    xmlns:props="clr-namespace:NMortgage.UI.Properties"
                    >

    <!-- Global Settings-->
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="Brushes.xaml"/>
        <ResourceDictionary Source="Fonts.xaml"/>

    </ResourceDictionary.MergedDictionaries>
    <Converters:EnumToResourceConverter x:Key="enumToResourceConverter" />
    <Converters:XNameToImageResourceConverter x:Key="xnameToImageConverter" />

    <Style x:Key="Numeric" TargetType="TextBlock">
        <Setter Property="HorizontalAlignment" Value="Right" />
    </Style>
    
    <Style TargetType="Border" x:Key="Section">
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="BorderBrush" Value="Gray" />
        <Setter Property="Padding" Value="10" />
        <Setter Property="Margin" Value="5" />
        <Setter Property="CornerRadius" Value="6" />
    </Style>

    <Style TargetType="Border" x:Key="PopupStyle">
        <Setter Property="CornerRadius" Value="6" />
        <Setter Property="Background" Value="White" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="BorderBrush" Value="Black" />
        <Setter Property="Padding" Value="4" />
        <Setter Property="Margin" Value="6" />
        <Setter Property="Border.Effect">
            <Setter.Value>
                <DropShadowEffect ShadowDepth="0" BlurRadius="20" Opacity=".7" />
            </Setter.Value>
        </Setter>
    </Style>

    <!--Button Style-->
    <Style TargetType="Button" x:Key="DefaultButtonStyle">
        <Setter Property="Background" Value="{StaticResource GrayBrush7}"/>
        <Setter Property="BorderBrush" Value="{StaticResource TextBoxBorderBrush}"/>
        <Setter Property="Foreground" Value="{StaticResource TextBrush}"/>
        <Setter Property="FontFamily" Value="{StaticResource ContentFontFamily}"/>
        <Setter Property="FontSize" Value="{StaticResource ContentFontSize}"/>
        <Setter Property="TextOptions.TextHintingMode" Value="Animated"/>
        <Setter Property="FontWeight" Value="SemiBold"/>
        <Setter Property="Padding" Value="5,6"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <Grid>
                        <Border x:Name="Background" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" CornerRadius="3"/>
                        <Rectangle x:Name="DisabledVisualElement" Fill="{StaticResource ControlsDisabledBrush}" IsHitTestVisible="false" Opacity="0" RadiusY="3" RadiusX="3"/>
                        <Border x:Name="MouseOverBorder" Background="{StaticResource GrayBrush8}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="3.5" Opacity="0"/>
                        <Border x:Name="PressedBorder" Background="{StaticResource GrayBrush5}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="3.5" Opacity="0"/>
                        <Rectangle x:Name="FocusRectangle" Stroke="{StaticResource TextBoxMouseOverInnerBorderBrush}" RadiusY="4" RadiusX="4" Margin="-1" Opacity="0" />
                        <Rectangle x:Name="FocusInnerRectangle" StrokeThickness="{TemplateBinding BorderThickness}" Stroke="{StaticResource TextBoxMouseOverBorderBrush}" RadiusX="3" RadiusY="3" Opacity="0" />
                        <ContentPresenter x:Name="contentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                    </Grid>

                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <!--<Setter TargetName="border" Property="Opacity" Value="0.7" />-->
                            <Setter Property="Foreground" Value="{StaticResource DisabledForegroundBrush}" />
                            <Setter Property="Content" Value=" " />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="TextBlock"
           x:Key="SectionHeader">
        <Setter Property="FontSize"
                Value="16" />
    </Style>
    <Style x:Key="PriceInput"
           TargetType="extToolkit:DecimalUpDown">
        <Setter Property="FormatString"
                Value="C2" />
        <Setter Property="Increment"
                Value=".01" />
        <Setter Property="Minimum"
                Value="0" />
    </Style>
    <Style x:Key="PercentageInput"
           TargetType="extToolkit:DecimalUpDown">
        <Setter Property="FormatString"
                Value="P" />
        <Setter Property="Increment"
                Value=".01" />
        <Setter Property="Minimum"
                Value="0" />
        <Setter Property="Maximum"
                Value="1" />
    </Style>

    <!--ScrollViewer Style-->
    <Style TargetType="ScrollViewer" x:Key="DefaultScrollViewerStyle">
        <Setter Property="Foreground" Value="{StaticResource TextBrush}"/>
        <Setter Property="Background" Value="{StaticResource ControlBackgroundBrush}"/>
        <Setter Property="HorizontalContentAlignment" Value="Left"/>
        <Setter Property="VerticalContentAlignment" Value="Top"/>
        <Setter Property="VerticalScrollBarVisibility" Value="Visible"/>
        <Setter Property="Padding" Value="4"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="BorderBrush">
            <Setter.Value>
                <SolidColorBrush Color="{StaticResource Gray4}"/>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ScrollViewer">
                    <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
                        <Grid Background="{TemplateBinding Background}">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="*"/>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>
                            <ScrollContentPresenter x:Name="ScrollContentPresenter" Cursor="{TemplateBinding Cursor}" ContentTemplate="{TemplateBinding ContentTemplate}" Margin="{TemplateBinding Padding}"/>
                            <Rectangle Grid.Column="1" Grid.Row="1" Visibility="Collapsed"/>
                            <ScrollBar x:Name="VerticalScrollBar" Grid.Column="1" IsTabStop="False" Maximum="{TemplateBinding ScrollableHeight}" Margin="0,-1,-3,-1" Minimum="0" Orientation="Vertical" Grid.Row="0" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Value="{TemplateBinding VerticalOffset}" ViewportSize="{TemplateBinding ViewportHeight}" Width="18"/>
                            <ScrollBar x:Name="HorizontalScrollBar" Grid.Column="0" Height="18" IsTabStop="False" Maximum="{TemplateBinding ScrollableWidth}" Margin="-1,0,-1,-3" Minimum="0" Orientation="Horizontal" Grid.Row="1" Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Value="{TemplateBinding HorizontalOffset}" ViewportSize="{TemplateBinding ViewportWidth}"/>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!--Control Label Style-->
    <Style x:Key="ControlLabelStyle" TargetType="TextBlock">
        <Setter Property="Foreground" Value="{StaticResource LabelTextBrush}"/>
        <Setter Property="FontFamily" Value="{StaticResource ContentFontFamily}"/>
        <Setter Property="FontSize" Value="{StaticResource LabelFontSize}"/>
        <Setter Property="TextOptions.TextHintingMode" Value="Animated"/>
    </Style>

    <!--TextBlock Style-->
    <Style TargetType="TextBlock" x:Key="DefaultTextBlockStyle">
        <Setter Property="Foreground" Value="{StaticResource TextBrush}"/>
        <Setter Property="FontFamily" Value="{StaticResource ContentFontFamily}"/>
        <Setter Property="FontSize" Value="{StaticResource ContentFontSize}"/>
        <Setter Property="TextOptions.TextHintingMode" Value="Animated"/>
    </Style>

    <Style x:Key="FlowLabelStyle" TargetType="TextBlock">
        <Setter Property="Foreground" Value="{StaticResource LabelTextBrush}"/>
        <Setter Property="FontFamily" Value="{StaticResource ContentFontFamily}"/>
        <Setter Property="FontSize" Value="{StaticResource LabelFontSize}"/>
        <Setter Property="TextWrapping" Value="NoWrap"/>
        <Setter Property="VerticalAlignment" Value="Center"/>
        <Setter Property="HorizontalAlignment" Value="Right" />
        <Setter Property="ClipToBounds" Value="True"/>
        <Setter Property="TextTrimming" Value="CharacterEllipsis"/>
        <Setter Property="TextOptions.TextHintingMode" Value="Animated"/>
        <Setter Property="MinWidth" Value="25" />
        <Setter Property="Width" Value="85" />
        <Setter Property="Margin" Value="10,1,0,1" />
    </Style>

    <!--Lists ScrollViewer Style-->
    <Style x:Key="ListsScrollViewerStyle" TargetType="ScrollViewer" BasedOn="{StaticResource DefaultScrollViewerStyle}">
        <Setter Property="Margin" Value="0,5,0,0" />
        <Setter Property="VerticalScrollBarVisibility" Value="Auto" />
        <Setter Property="HorizontalScrollBarVisibility" Value="Auto" />
        <Setter Property="BorderThickness" Value="0" />
    </Style>

    <Style x:Key="VGridSplit" TargetType="GridSplitter">
        <Setter Property="HorizontalAlignment" Value="Right" />
        <Setter Property="ResizeBehavior" Value="PreviousAndNext" />
        <Setter Property="VerticalAlignment" Value="Stretch" />
        <Setter Property="Background" Value="#FFBCBCBC" />
        <Setter Property="Width" Value="1" />
        <Setter Property="Margin" Value="0,10,0,10" />
    </Style>
    
    <Style x:Key="HGridSplit" TargetType="GridSplitter">
        <Setter Property="HorizontalAlignment" Value="Stretch" />
        <Setter Property="ResizeBehavior" Value="PreviousAndNext" />
        <Setter Property="VerticalAlignment" Value="Top" />
        <Setter Property="Background" Value="#FFBCBCBC" /> 
        <Setter Property="Height" Value="1" />
        <Setter Property="Margin" Value="10,0,10,0" />
    </Style>

    <!--List TextBlock Style-->
    <Style TargetType="ItemsControl" x:Key="ItemsControlListStyle">
        <Setter Property="Background"  Value="{StaticResource ControlBackgroundBrush}"/>
    </Style>

    <!--List TextBlock Style-->
    <Style TargetType="TextBlock" x:Key="ListTextBlockStyle" BasedOn="{StaticResource DefaultTextBlockStyle}">
        <Setter Property="TextWrapping" Value="NoWrap"/>
        <Setter Property="ClipToBounds" Value="True"/>
        <Setter Property="TextTrimming" Value="CharacterEllipsis"/>
        <Setter Property="TextOptions.TextHintingMode" Value="Animated"/>
    </Style>

    <!--ListImageButton Styles-->
    <Style TargetType="Button" x:Key="DefaultImageResKeyButton">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Border Name="ImageBorder" Padding="1" BorderThickness="1" CornerRadius="2" 
                                BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}"
                                HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
                        <Image Source="{Binding   RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}, 
                                    Converter={StaticResource xnameToImageConverter}, ConverterParameter={x:Static props:Resources.ResourceManager}}"
                               HorizontalAlignment="Center" VerticalAlignment="Center" Stretch="Uniform" />
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="ImageBorder" Property="BorderBrush" Value="DodgerBlue" />
                            <Setter TargetName="ImageBorder" Property="Background">
                                <Setter.Value>
                                    <SolidColorBrush>
                                        <SolidColorBrush.Color>
                                            <Color A="200" R="194" G="224" B="255" />
                                        </SolidColorBrush.Color>
                                    </SolidColorBrush>
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter TargetName="ImageBorder" Property="BorderBrush" Value="DodgerBlue" />
                            <Setter TargetName="ImageBorder" Property="Background" Value="LightSkyBlue" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Height" Value="24" />
        <Setter Property="Width" Value="24" />
        <Setter Property="Padding" Value="0,0"/>
    </Style>
    <Style TargetType="Button" x:Key="SmallImageResKeyButton" BasedOn="{StaticResource DefaultImageResKeyButton}">
        <Setter Property="Height" Value="16" />
        <Setter Property="Width" Value="16" />
    </Style>

    <!-- Validating Controls-->
    <Style x:Key="ValidatingControl" TargetType="{x:Type Control}">
        <Setter Property="Margin" Value="1,1,15,1" />
        <Setter Property="MinWidth" Value="50" />
        <Setter Property="Validation.ErrorTemplate">
            <Setter.Value>
                <ControlTemplate>
                    <DockPanel DockPanel.Dock="Right" >
                        <AdornedElementPlaceholder />
                        <Image Source="/NMortgage.UI;component/Themes/Default/Images/warning_64.png" 
                               ToolTip="{Binding Path=AdornedElement.Tag, 
                                    RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Adorner}}}" 
                               Width="15" Height="15" Panel.ZIndex="100" />
                    </DockPanel>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="Validation.HasError" Value="True">
                <Setter Property="Tag" Value="{Binding RelativeSource={x:Static RelativeSource.Self}, 
                        Path=(Validation.Errors)[0].ErrorContent}" />
            </Trigger>
        </Style.Triggers>
    </Style>
    <Style x:Key="ValidatingDecimalBox" TargetType="{x:Type extToolkit:DecimalUpDown}" BasedOn="{StaticResource ValidatingControl}"  >
        <Setter Property="FormatString" Value="F2" />
        <Setter Property="Increment" Value=".01" />
        <Setter Property="Minimum" Value="0" />
    </Style>
    <Style x:Key="ValidatingIntBox" TargetType="{x:Type extToolkit:IntegerUpDown}" BasedOn="{StaticResource ValidatingControl}"  >
        <Setter Property="FormatString" Value="D" />
        <Setter Property="Increment" Value="1" />
        <Setter Property="Minimum" Value="0" />
    </Style>
    <Style x:Key="ValidatingDateBox" TargetType="{x:Type wpf:DatePicker}" BasedOn="{StaticResource ValidatingControl}" >
        <Setter Property="SelectedDateFormat" Value="Short" />
    </Style>




    <Style TargetType="Button" x:Key="DialogOKCancelButton" BasedOn="{StaticResource DefaultButtonStyle}">
        <Setter Property="Width" Value="45"/>
        <Setter Property="Margin" Value="1,3,1,3"/>
    </Style>

    <!-- Implicit Styles -->
    <!-- When defining your own styles, set "based on" the same way to keep control theming -->
    <Style TargetType="Button" BasedOn="{StaticResource DefaultButtonStyle}" />
    <Style TargetType="TextBlock" BasedOn="{StaticResource DefaultTextBlockStyle}" />


</ResourceDictionary>